home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / StreamConnection.h < prev    next >
C/C++ Source or Header  |  1992-08-10  |  2KB  |  92 lines

  1. #ifndef StreamConnection_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define StreamConnection_First
  7.  
  8. #include "System.h"
  9. #include "Data.h"
  10.  
  11. #define SERVERNAME "ET++clipboard"
  12. #define SERVICENAME "et++clipboard"
  13.  
  14. extern bool gIACDebug;
  15.  
  16. class MemBuf;
  17. class SeqCollection;
  18. class StreamConnection;
  19.  
  20. //---- Message -----------------------------------------------------------------
  21.  
  22. struct block {
  23.     int len, pos;
  24.     char *buf;
  25.     
  26.     block();
  27.     ~block();
  28. };
  29.  
  30. class Message : public Object {
  31. public:
  32.     int from, to, serial;
  33.     block data[2];
  34.  
  35. public:
  36.     Message();
  37.     Message(int to, int from, int reply, char *buf, int l= -1, bool makecopy= TRUE);
  38.     int Read(int fd);
  39.     int Write(int fd);
  40.     void Print(char *from, char *to);
  41.     bool IsReply()
  42.     { return serial < 0; }
  43. };
  44.  
  45. //---- StreamConnection --------------------------------------------------------
  46.  
  47. class StreamConnection : public SysEvtHandler {
  48. protected:
  49.     Message *rm;
  50.     SeqCollection *wqueue;
  51.     OrdCollection *queue;
  52.     bool error;
  53.     int serial, sid;
  54.     char *name;
  55.     
  56.     bool Open(int fd);
  57.  
  58. public:
  59.     int IntSendTo(int to, int reply, char *req, char *buf, int l);
  60.     int SendTo(int to, char *req, char *buf= 0, int l= -1);
  61. public:
  62.     MetaDef(StreamConnection);
  63.     StreamConnection(int);
  64.     ~StreamConnection();
  65.     void SetName(char*);
  66.     
  67.     void SendMessage(Message *m);
  68.     Message *WaitForReply(int seq, int timeout);
  69.     int DrainOutput(int timeout);
  70.     int WaitForMessage(int timeout);
  71.     void Dispatch0(Message *m);
  72.     bool Reconnect();
  73.  
  74.     // obsolete interface
  75.     int Talk(int client, char *req, char *buf= 0, int len= -1,
  76.                         char **retbuf= 0, int *retlen= 0);
  77.     void Talk(char *prog, char *va_(fmt), ...);
  78.  
  79.     virtual void Dispatch(int from, char *req, char *buf, int len,
  80.                             char *&retbuf, int &retlen);
  81.     virtual bool Dispatch2(char *req, char *buf, int len,
  82.                 char *&retbuf, int &retlen, Message *m);
  83.     int Error(int code);
  84.  
  85. protected:
  86.     bool HasInterest(SysEventCodes code);
  87.     void Notify(SysEventCodes, int);
  88. };
  89.  
  90. #endif
  91.  
  92.